package org.jader.bolao.text.html;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.StringReader;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;

public class HTMLGenerator {
	
	private HTMLGenerator() {}
	
	public static void generatePage(File html, String xml, File xslt) {
		TransformerFactory tFactory = TransformerFactory.newInstance();

	    try {
	    	Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(xslt));

			transformer.transform(new javax.xml.transform.stream.StreamSource(new StringReader(xml)),
			   new javax.xml.transform.stream.StreamResult( new FileOutputStream(html)));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (TransformerException e) {
			e.printStackTrace();
		}
	}
	
}
